<template>
<view class="container" :style="'height:' + (OrganizesshowWay==1? '100%':'')"> 
<!-- 头部 -->
 <view class="typeSearchContainer"> 
    <view class="search_input_bg">
      <view class="search_input">
        <view class="search_input_left">
          <image class="input_img" src="https://image1.sansancloud.com/xianhua/2018_9/14/16/25/0_222.jpg?x-oss-process=style/preview_120"></image>
          <input class="input" @confirm="getSearchOrganizeName" :value="searchOrganizesName" placeholder="搜索组织名"></input>
        </view>
        <view class="empty_button" @tap="getSearchOrganizeName"><text>x</text></view>
      </view>
    </view>
    <!-- <view class="typeSearch">
     <view class='flexCenter' data-index="0" style='width:85%'>
       <scroll-view scroll-x class="tab-h" scroll-into-view="{{'tab_'+positionTab}}" scroll-with-animation='true'>
         <view  wx:for="{{setting.platformSetting.categories}}"
          wx:for-item="type" wx:key="{{index}}" data-type="{{type}}"
          bindtap='bindTypeItem' id="{{'tab_'+type.id}}" class='tab-item' style='color:{{type.colorAtive}};border-bottom:{{type.active?"2rpx solid "+type.colorAtive:""}}'>{{type.name}}</view>
       </scroll-view>
     </view>
    
     <view class='flexCenter' bindtap='bindOrganizeshowWay' style='width:100rpx'>
        <view class='border_left'></view>
        <block wx:if="{{OrganizeshowWay ==1}}">
          <image src='https://image1.sansancloud.com/xianhua/2018_9/13/12/1/42_584.jpg'></image>
        </block>
        <block wx:if="{{OrganizeshowWay == 2}}">
          <image src='https://image1.sansancloud.com/xianhua/2018_9/14/14/10/32_257.jpg'></image>
        </block>
     </view>
    </view> -->
  </view>
  <organizes-list-component class="organizesList" ></organizes-list-component>
  <!-- v-if="options" :receiveData="options" :params="params" -->
</view>
</template>

<script>
// import organizesList from "../../view/partials/organizes_list/index";

export default {
  data() {
    return {
      options: null,
      OrganizesshowWay: 2,
      searchOrganizesName: '',
      /* 全部参数 */
      params: {
        name: "",
        addressStr: "",
        page: 1,
        latitude: '0',
        longitude: '0'
      }
    };
  },
  props: {},

  /* 组件事件集合 */

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    options.type = "typeTwo";
    that.setData({
      options: options
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    let that = this;
    that.setData({
      searchOrganizesName: ""
    });
    console.log("===selectComponent===",that.selectComponent(".organizesList"))
    that.selectComponent(".organizesList").pullDownRefreshFun();
    wx.hideNavigationBarLoading(); //完成停止加载

    wx.stopPullDownRefresh(); //停止下拉刷新
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    let that = this;
    console.log("===selectComponent===",that.selectComponent(".organizesList"))
    that.selectComponent(".organizesList").reachBottomFun();
  },
  methods: {
    /* 查找商品 */
    getSearchOrganizeName: function (e) {
      console.log(e);
      let that = this;

      if (e.detail.value) {
        that.params.name = e.detail.value;
      } else {
        that.params.name = '';
      }

      that.setData({
        searchOrganizesName: that.params.name
      });
      that.selectComponent(".organizesList").getSearchOrganizeName(that.params);
    },

    /* 商品显示方法 */
    bindOrganizesshowWay: function () {
      if (this.OrganizesshowWay == 1) {
        this.setData({
          OrganizesshowWay: 2
        });
      } else {
        this.setData({
          OrganizesshowWay: 1
        });
      }
    },
    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  }
};
</script>
<style>
@import "./index.css";
</style>